//
//  DDLeftViewController.m
//  ialone
//
//  Created by lanou on 16/1/11.
//  Copyright © 2016年 JasperSong. All rights reserved.
//

#import "DDLeftViewController.h"
#import "DDSettingsViewController.h"
#import "DDSoundViewController.h"
#import "DDLeftView.h"
#import "DDCalendarViewController.h"
#import "DDSearchViewController.h"
@interface DDLeftViewController ()

@property (nonatomic, strong) DDLeftView *left;

@end

@implementation DDLeftViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    
    _left = [[DDLeftView alloc]initWithFrame:self.view.bounds];
    
    [_left.settingsButton addTarget:self action:@selector(settingsButton:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    [_left.backButton addTarget:self action:@selector(back:) forControlEvents:(UIControlEventTouchUpInside)];
    [_left.voiceButton addTarget:self action:@selector(voiceButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [_left.textButton addTarget:self action:@selector(textButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [_left.videoButton addTarget:self action:@selector(videoButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [_left.pageButton addTarget:self action:@selector(back:) forControlEvents:(UIControlEventTouchUpInside)];
    [_left.calendarButton addTarget:self action:@selector(calendarButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [_left.searchButton addTarget:self action:@selector(searchButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:_left];
    
    
    
}


- (void)back:(UIButton *)button{

    
    [UIView animateWithDuration:0.3 animations:^{
        for (int i = 0; i < 2; i ++){
            UIButton *button = (UIButton *)[self.view viewWithTag:3400 + i];
            button.transform = CGAffineTransformScale(button.transform, 0.1, 0.1);
        }
        UILabel *label2 = (UILabel *)[self.view viewWithTag:3301];
        label2.transform = CGAffineTransformScale(label2.transform, 0.1, 1);
        
    } completion:^(BOOL finished) {
        for (int i = 0; i < 2; i ++){
            UIButton *button = (UIButton *)[self.view viewWithTag:3400 + i];
            button.hidden = YES;
        }
        UILabel *label2 = (UILabel *)[self.view viewWithTag:3301];
        label2.hidden = YES;
        
        [UIView animateWithDuration:1 animations:^{
            self.view.frame = CGRectMake(-kScreenWidth, 0, kScreenWidth, kScreenHeight);
        }];
        UILabel *label = (UILabel *)[self.view viewWithTag:3300];
        for (int i = 0; i < 6; i++){
            UIButton *button = (UIButton *)[self.view viewWithTag:2700 + i];
            [UIView animateWithDuration:1.2 - 0.2 * i  animations:^{
                button.frame = CGRectMake(0, label.bottom + 40 + 65 * i, 135, 45);
            }];
        }
        
    }];
    
}

- (void)voiceButton:(UIButton *)button
{
    DDSoundViewController *soundVC = [[DDSoundViewController alloc]init];
    
    soundVC.str = @"http://static.owspace.com/index.php?m=Home&c=Api&a=getList&model=3&p=1&client=iphone&page_id=0&create_time=0&device_id=B709CBC5-0E2F-4C89-9E24-6AFBBA86C58C&iOS_version=1.0.0";
    soundVC.str1 = @"声   音";
    
    [self.navigationController pushViewController:soundVC animated:YES];
}

- (void)textButton:(UIButton *)button
{
    DDSoundViewController *soundVC = [[DDSoundViewController alloc]init];
    
    soundVC.str = @"http://static.owspace.com/index.php?m=Home&c=Api&a=getList&model=1&p=1&client=iphone&page_id=0&create_time=0&device_id=B709CBC5-0E2F-4C89-9E24-6AFBBA86C58C&iOS_version=1.0.0";
    
    soundVC.str1 = @"文   字";
    
    [self.navigationController pushViewController:soundVC animated:YES];
}

- (void)videoButton:(UIButton *)button
{
    DDSoundViewController *soundVC = [[DDSoundViewController alloc]init];
    
    soundVC.str = @"http://static.owspace.com/index.php?m=Home&c=Api&a=getList&model=2&p=1&client=iphone&page_id=0&create_time=0&device_id=B709CBC5-0E2F-4C89-9E24-6AFBBA86C58C&iOS_version=1.0.0";
    
    soundVC.str1 = @"影   像";
    
    [self.navigationController pushViewController:soundVC animated:YES];
}

-(void)calendarButton:(UIButton *)button
{
    DDCalendarViewController *calendarVC = [[DDCalendarViewController alloc]init];
    calendarVC.str = @"http://static.owspace.com/index.php?m=Home&c=Api&a=getList&model=4&p=1&client=iphone&page_id=0&create_time=0&device_id=B709CBC5-0E2F-4C89-9E24-6AFBBA86C58C&iOS_version=1.0.0";
    calendarVC.str1 = @"单 向 历";
    [self.navigationController pushViewController:calendarVC animated:YES];
}

-(void)searchButton:(UIButton *)button
{
    DDSearchViewController *searchVC = [[DDSearchViewController alloc]init];
    searchVC.str1 = @"搜   索";
    [self.navigationController pushViewController:searchVC animated:YES];
}
- (void)settingsButton:(UIButton *)button
{
    DDSettingsViewController *setting = [[DDSettingsViewController alloc]init];
    
    [self.navigationController pushViewController:setting animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
